class NumberContainers
{
public:
    NumberContainers()
    {
    }

    void change(int index, int number)
    {
        if (nums.count(index))
        {
            int originNum = nums[index];
            if (number == originNum)
            {
                return;
            }
            numIndexs[originNum].erase(index);
            if (numIndexs[originNum].empty())
            {
                numIndexs.erase(originNum);
            }
        }
        nums[index] = number;
        numIndexs[number].insert(index);
    }

    int find(int number)
    {
        if (!numIndexs.count(number))
        {
            return -1;
        }
        return *numIndexs[number].begin();
    }

private:
    unordered_map<int, set<int>> numIndexs;
    unordered_map<int, int> nums;
};

/**
 * Your NumberContainers object will be instantiated and called as such:
 * NumberContainers* obj = new NumberContainers();
 * obj->change(index,number);
 * int param_2 = obj->find(number);
 */